
const userDao = require("../../models/user/user");
//加密
const { createHash } = require('crypto');

module.exports={
    //根据用户名和密码查询
    async getuserByNameAndPwd(name,password){
       return await userDao.findOne({
           name,
           password:createHash("sha256")
                    .update(password)
                    .digest("hex")
        }).exec();
    },
    async getuserByName(name){
        return await userDao.findOne({name}).exec();      
    },
    async insertUser(name,pwd){
        return await userDao.create({
            name,
            password:createHash("sha256")
                     .update(pwd)
                     .digest("hex")
         });    }
}